﻿using System;
using System.Collections.Generic;
using System.Text;
using NuMvvm;
using NuMvvm.Services;
using Todo.ViewModels;
using Todo.Services;

namespace Todo
{
    #if !TEST
        
    using NuIoc;

    public partial class App
    {
        private static readonly Container container = new Container();

        public static void SetUp()
        {
            ViewModelLocationService.SetViewModelFactory((type) => container.Resolve(type));

            RegisterServices();
            RegisterViewModels();
        }

        public static void RegisterServices()
        {
            container.RegisterType<IDataService, DataService>();
            container.RegisterType<IDialogService, DialogService>();
            container.RegisterType<INavigationService, NavigationService>();
        }

        public static void RegisterViewModels()
        {
            container.RegisterType<MainViewModel>().AsTransient();
            container.RegisterType<ItemViewModel>().AsTransient();
        }

        public static INavigationService NavigationService
        {
            get
            {
                return container.Resolve<INavigationService>();
            }
        }

    }
    
    #endif
}
